﻿using System;
using BLL;
using Model;

public partial class ProductPackage_PackageProductSNforPrinter : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindCustoms();
            BindProductTypes();
        }
    }

    protected void BindCustoms()
    {
        Customer cust = new Customer();
        this.DropDownList1.DataSource = cust.LoadEntities();
        this.DropDownList1.DataTextField = "CustomerName";
        this.DropDownList1.DataValueField = "CustomerID";
        this.DropDownList1.DataBind();
    }

    protected void BindProductTypes()
    {
        ProductType pt = new ProductType();
        this.DropDownList2.DataSource = pt.GetProductTypesbyCustomerID(this.DropDownList1.SelectedValue);
        this.DropDownList2.DataTextField = "ProductTypeName";
        this.DropDownList2.DataValueField = "ProductTypeID";
        this.DropDownList2.DataBind();
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        BindProductTypes();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        BindTests();
    }

    private void BindTests()
    {
        int n = int.Parse(this.TextBox3.Text);
        string var_productTypeID = this.DropDownList2.SelectedItem.Text.Trim();

        PackageProduct test = new PackageProduct();
        this.GridView1.DataSource = test.GetPackagedProductsbyPIDDT_forPrinter(var_productTypeID, n);
        this.GridView1.DataBind();
    }
}
